#include "Avalon/Codecs/Decoder.hpp"
#include "Avalon/IO/Buffer.hpp"

using namespace Avalon;
using namespace Avalon::Codecs;
using namespace Avalon::IO;

Decoder::~Decoder() {}

Buffer Decoder::Decode(const void* data, int size) {
  Buffer destination;
  Decode(data, size, &destination);
  return destination;
}

Buffer Decoder::Decode(const Buffer& data) {
  return Decode(data.GetData(), data.GetSize());
}

void Decoder::Decode(const Buffer& source, void* destination,
    int destinationSize, int* decodedSize) {
  Decode(source.GetData(), source.GetSize(), destination, destinationSize,
    decodedSize);
}

void Decoder::Decode(const Buffer& source, Buffer* destination,
    int* decodedSize) {
  Decode(source.GetData(), source.GetSize(), destination, decodedSize);
}

void Decoder::DecodeInPlace(void* data, int size, int* decodedSize) {
  Decode(data, size, data, size, decodedSize);
}

void Decoder::DecodeInPlace(Buffer* data, int* decodedSize) {
  DecodeInPlace(data->GetMutableData(), data->GetSize(), decodedSize);
}
